package com.huazai.out_school_manager.Servlet;

import com.huazai.out_school_manager.Dao.UserDao;
import com.huazai.out_school_manager.Dao.realization.UserDaoReal;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "decide", value = "/decide")
public class DecideServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        UserDao userDao = new UserDaoReal();
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter pw = response.getWriter();
        String applyID = request.getParameter("applyID");
        String result = request.getParameter("result");

        if ( userDao.updateSubmit(applyID, result) ) {
            pw.print("<h1 align=\"center\">审批成功</h1>");
        }
        else {
            pw.print("<h1 align=\"center\">审批失败</h1>");
        }
        pw.print("<a href='javascript:void(0)' onclick='window.history.back()'>返回上一级</a>");

    }
}
